<?php
ob_start();
session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
}
$lang = $_SESSION['lang'];
if ($lang == '')
    $lang = 'EN';
if (!isset($_REQUEST['page'])) {
    $page = 1;
} else {
    $page = $_REQUEST['page'];
}
$rows_per_page = $_SESSION['rows_page'];
$page_start = ( $page - 1 ) * $rows_per_page;
$page_end = $page * $rows_per_page;

include("operations/get_lang.php");
$value = getlang();
include($value);
if (!isset($_SESSION['user'])) {
    header('Location: login.php?timeout=on');
} else {
    $username = $_SESSION['fullname'];
    $id_employee = $_SESSION['IDEmployee'];
}
if($_SESSION['role']!=2){
	echo $_SESSION['role'];
	header("Location: ../index.php");
}

include 'operations/connection.php';


if (isset($_REQUEST['accept'])) {
    $mxoa = $_REQUEST['xacnhan'];
    for ($i = 0; $i < count($mxoa); $i++) {
        mysql_query("update list_reference l set id_status = 1 WHERE l.id_group = (SELECT a.IDGroupApprove FROM approvedoc a WHERE a.IDApproveDoc='" . $mxoa[$i] . "') 
    		 															AND l.id_employee='$id_employee'");
        //if($xoa[1]==13 || $xoa[1]==15){
        //	mysql_query("delete from buying_document where buying_document.document_id='".$xoa[0]."'");
        //}else{
        //	mysql_query("delete from ap_advance where ap_advance.document_id='".$xoa[0]."'");
        //}
        //mysql_query("delete from approvedoc  WHERE IDApproveDoc='".$xoa[0]."'");
    }
}

$content = "content/list-receiver-pending-content.php";
if (isset($_REQUEST['content'])) {

    $content = "content/" . $_REQUEST['content'] . ".php";
}



if (isset($_REQUEST['action']))
    $action = $_REQUEST['action'];
if (isset($_REQUEST['id']))
    $id = $_REQUEST['id'];

if (isset($_REQUEST['type'])) {
    $type = $_REQUEST['type'];

    if ($type == 7)
        $content = 'content/view-form7-content.php';
    else if ($type == 12)
        $content = 'content/view-form12-content.php';
    else if ($type == 13)
        $content = 'content/view-form13-content.php';
    else if ($type == 15)
        $content = 'content/view-form15-content.php';
    else if ($type == 14)
        $content = 'content/view-form14-content.php';
    else if ($type == 16)
        $content = 'content/view-form16-content.php';
    else if ($type == 17)
        $content = 'content/view-form17-content.php';
    else if ($type == 18)
        $content = 'content/view-form18-content.php';
    else if ($type == 19)
        $content = 'content/view-form19-content.php';
    else if ($type == 11)
        $content = 'content/view-form11-content.php';
    
	if ($_SESSION['action'] == "re_not_approve") {
	    mysql_query("UPDATE listapprove SET isView='1' WHERE (IDGroupApprove=(SELECT a.IDGroupApprove FROM approvedoc a WHERE a.IDApproveDoc='$id'));");
	}
	if ($_SESSION['action'] == "re_reference_waiting") {
	    mysql_query("UPDATE list_reference SET isView='1' WHERE (id_group=(SELECT a.IDGroupApprove FROM approvedoc a WHERE a.IDApproveDoc='$id'))");
	}
}



echo $_SESSION['back'];

$title = $_SESSION['browser'];





if ($_SESSION['role'] == 1) {

    require("MainTemplateAdmin.php");
} else {
    require("MainTemplate.php");
}
ob_flush();
?>